package solitaire.gui;

import java.awt.Container;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MouseFrame extends javax.swing.JFrame {
	private JMenuBar mainJMenuBar;
	private JMenu fileJMenu;
	private JMenu editJMenu;
	private JMenu helpJMenu;
	private JMenuItem aboutMenuItem;
	private JMenuItem rulesMenuItem;
	private JMenuItem quitJMenuItem;
	private JMenuItem newSolitaireMenuItem;
	private JMenuItem undoMenuItem;
	private JMenuItem redoMenuItem;
	public static final int WIDTH = 800;
	public static final int HEIGHT = 600;
	public enum DrawObjectType{Box, Image}

	/*
	* This is the main method that displays the JFrame.
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MouseFrame inst = new MouseFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	} 

	/*
	 * This is the JFrame that uses the predefined JFrame assets and initiates the initGUI function.
	 */
	public MouseFrame() {
		initGUI();
		MousePanel panel = new MousePanel();
        Container contentPane = getContentPane();
        contentPane.add(panel);
	}

	/*
	 * This is the GUI initiation function. It throws an error Exception if there is a problem with
	 * any of the components that are to be drawn.
	 */
	private void initGUI() {
		try {
			window(); //The size of the window when you run the program
			fileMenuBar(); //The bar containing "File"
			editMenuBar(); //The bar containing "Edit"
			helpMenuBar(); //The bar containing "Help"

			pack();	//To set the size of the program vs screen resolution
			
	        setSize( WIDTH, HEIGHT );
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/*
	 * This is the window function. It only adds the possibility of disposing of the window on close.
	 */
	private void window(){
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	}

	/*
	 *
	 * This GUI function draws the menu bar itself and adds the "File" menuItem to the bar.
	 * It also runs the functions that add the "New Solitaire" and the "Quit" item to the "File" menu.
	 *
	 */
	private void fileMenuBar(){
		mainJMenuBar = new JMenuBar();
		setJMenuBar(mainJMenuBar);
		fileJMenu = new JMenu();
		mainJMenuBar.add(fileJMenu);
		fileJMenu.setText("File");
		fileJMenu.setPreferredSize(new java.awt.Dimension(35, 21));
		fileNewMenuItem();
		fileOpenMenuItem();
		fileSaveMenuItem();
		fileQuitMenuItem();
	}

	/*
	 *
	 * This GUI function draws the "New Solitaire" menuItem, initiated by the "File" menu.
	 *
	 */
	private void fileNewMenuItem(){
		newSolitaireMenuItem = new JMenuItem();
		fileJMenu.add(newSolitaireMenuItem);
		newSolitaireMenuItem.setText("New Solitaire");
		newSolitaireMenuItem.setBounds(0, 0, 35, 20);
	}

	/*
	 *
	 * This GUI function draws the "Save" menuItem, initiated by the "File" menu.
	 *
	 */
	private void fileSaveMenuItem(){
		newSolitaireMenuItem = new JMenuItem();
		fileJMenu.add(newSolitaireMenuItem);
		newSolitaireMenuItem.setText("Save");
		newSolitaireMenuItem.setBounds(0, 0, 35, 20);
	}
	/*
	 *
	 * This GUI function draws the "Open" menuItem, initiated by the "File" menu.
	 *
	 */
	private void fileOpenMenuItem(){
		newSolitaireMenuItem = new JMenuItem();
		fileJMenu.add(newSolitaireMenuItem);
		newSolitaireMenuItem.setText("Open");
		newSolitaireMenuItem.setBounds(0, 0, 35, 20);
	}

	/*
	 *
	 * This GUI function draws the "Quit" menuItem, initiated by the "File" menu.
	 *
	 */
	private void fileQuitMenuItem(){
		quitJMenuItem = new JMenuItem();
		fileJMenu.add(quitJMenuItem);
		quitJMenuItem.setText("Quit");
		quitJMenuItem.setBounds(0, 0, 33, 20);
	}
	
	/*
	 * 
	 * This GUI function adds the "Edit" menu to the menuBar.
	 * It also initiates the functions to draw the "Undo" and the "Redo" menu items to the Help menu.
	 * 
	 */
	private void editMenuBar(){
		editJMenu = new JMenu();
		mainJMenuBar.add(editJMenu);
		editJMenu.setText("Edit");
		editJMenu.setPreferredSize(new java.awt.Dimension(40, 23));
		editUndoMenuItem();
		editRedoMenuItem();
	}
	
	/*
	 * 
	 * This GUI function draws the "Undo" menu item to the "Help" menu.
	 * 
	 */	
	private void editUndoMenuItem(){
		undoMenuItem = new JMenuItem();
		editJMenu.add(undoMenuItem);
		undoMenuItem.setText("Undo");
		undoMenuItem.setBounds(0, 0, 39, 19);
	}
	
	/*
	 * 
	 * This GUI function draws the "Redo" menu item to the "Help" menu.
	 * 
	 */	
	private void editRedoMenuItem(){
		redoMenuItem = new JMenuItem();
		editJMenu.add(redoMenuItem);
		redoMenuItem.setText("Redo");
		redoMenuItem.setBounds(0, 0, 39, 20);
	}

	/*
	 *
	 * This GUI function adds the "Help" menu to the menuBar.
	 * It also initiates the functions to draw the "Help" and the "About" menu items to the Help menu.
	 *
	 */
	private void helpMenuBar(){
		helpJMenu = new JMenu();
		mainJMenuBar.add(helpJMenu);
		helpJMenu.setText("Help");
		helpJMenu.setPreferredSize(new java.awt.Dimension(40, 23));
		helpRulesMenuItem();
		aboutRulesMenuItem();
	}

	/*
	 *
	 * This GUI function draws the "Rules" menu item to the "Help" menu.
	 *
	 */
	private void helpRulesMenuItem(){
		rulesMenuItem = new JMenuItem();
		helpJMenu.add(rulesMenuItem);
		rulesMenuItem.setText("Rules");
		rulesMenuItem.setBounds(0, 0, 39, 19);
	}

	/*
	 *
	 * This GUI function draws the "About" menu item to the "Help" menu.
	 *
	 */
	private void aboutRulesMenuItem(){
		aboutMenuItem = new JMenuItem();
		helpJMenu.add(aboutMenuItem);
		aboutMenuItem.setText("About");
		aboutMenuItem.setBounds(0, 0, 39, 20);
	}
}

